package com.jia.train.seat.controller;

import com.jia.train.global.page.PageResponse;
import com.jia.train.global.response.BaseResponse;
import com.jia.train.seat.request.DailyTrainCarriageQueryRequest;
import com.jia.train.seat.request.DailyTrainCarriageSaveRequest;
import com.jia.train.seat.response.DailyTrainCarriageQueryResponse;
import com.jia.train.seat.response.DailyTrainCarriageSaveResponse;
import com.jia.train.seat.service.DailyTrainCarriageService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/daily/carriage")
public class DailyTrainCarriageController {

    @Resource
    private DailyTrainCarriageService dailyTrainCarriageService;

    @PostMapping("/insert")
    public BaseResponse<DailyTrainCarriageSaveResponse> insertDailyTrainCarriage(@Valid @RequestBody DailyTrainCarriageSaveRequest request) {
        DailyTrainCarriageSaveResponse response = dailyTrainCarriageService.insert(request);
        return new BaseResponse<>(response);
    }

    @GetMapping("/query")
    public BaseResponse<PageResponse<DailyTrainCarriageQueryResponse>> query(@Valid DailyTrainCarriageQueryRequest request) {
        PageResponse<DailyTrainCarriageQueryResponse> responseList = dailyTrainCarriageService.selectPage(request);
        return new BaseResponse<>(responseList);
    }

    @DeleteMapping("/delete/{id}")
    public BaseResponse<String> delete(@PathVariable Long id) {
        dailyTrainCarriageService.deleteDailyTrainCarriage(id);
        return new BaseResponse<>("success");
    }

}
